package com.open.launcher.helper;


import android.util.Log;

import com.open.launcher.bean.RequestDto;
import com.open.launcher.bean.allchannels.Program;
import com.open.launcher.callback.IRequestCallback;
import com.open.launcher.callback.IRequestLisenter;
import com.open.launcher.utils.OkGoUtil;

import static android.content.ContentValues.TAG;

/**
 * Created by wendal on 2017/9/16.
 */

public class VodItemHelper {
    private IRequestCallback callback;

    public VodItemHelper() {
    }

    public void setCallback(IRequestCallback callback) {
        this.callback = callback;
    }

    public void loadData(String url) {
        OkGoUtil<Program> okGoUtil = new OkGoUtil<>(Program.class, OkGoUtil.TYPE_DATA, new IRequestLisenter() {
            @Override
            public void onSuccessData(RequestDto dto) {
                Log.i(TAG, "onSuccessData: ");
                if (dto != null) {
                    if (callback != null) {
                        callback.onLoadComplete("", 0, 0, dto.getData());
                        Log.i(TAG, "onSuccessData: ");
                    }
                }
            }

            @Override
            public void onErrer(int code, String errMsg) {
                Log.i(TAG, "onErrer: ");
                if (callback != null) {
                    callback.onFailed(code + "", errMsg);
                }
            }
        });
        okGoUtil.requestGet(url);
    }
}
